<?php
class Table_Page extends CF_Db_Table_Abstract
{
	protected $_name = '##_pages';
	
	public function getList($columns = '*', $where = null, $order = null, $limit = 50, $offset = 0)
	{
		return $this->select($columns, $where, $order, $limit, $offset)
					->getAll();
	}
	
	public function update()
	{
		
	}
	
	public function insert($data)
	{
		# insert to table pages
		$time = time();
		$pageData = array(
			'created_time' => $time,
			'user_id' => CF_Auth::getInstance()->getStorage()->getData()->id
		);
		
		try{
			$id = parent::insert($pageData);
			$data['page_id'] = $id;
			
			### insert to table pages_trans (apply for all languages)
			$tbPageTrans = new Table_PageTrans();
			$tbPageTrans->insert($data);
			
			return array('id' => $id, 'created_time' => $time);
			
		}catch (CF_Db_Exception $e){
			return $e->getMessage();
		}
	}
}